﻿using System;
using System.Collections.ObjectModel;
using System.Threading.Tasks;
using AvaloniaApplicationDemo.Models;

namespace AvaloniaApplicationDemo.IServices;

public interface IModbusManager
{
    // 新增状态变更事件
    event EventHandler<ModbusStatusEventsAgrs>? StatusChanged;

    // 数据解析器（允许外部注入）
    Func<ushort[], int, ModbusDeviceData> DataParser { get; set; }

    /// <summary>
    /// 连接设备
    /// </summary>
    /// <param name="slaveInfo">从站设备信息</param>
    /// <param name="deviceModel">设备模型</param>
    /// <param name="isAutoTest">是否自动测试</param>
    /// <returns></returns>
    Task<bool> ConnectAsync(SlaveInfo slaveInfo, DeviceModel deviceModel, bool isAutoTest = false);

    Task<bool> DisconnectAsync(DeviceModel deviceModel);
    Task ReadDataPointAsync(SlaveInfo slaveInfo, DeviceModel deviceModel);

    Task<bool> SaveSettingsDataAsync(SlaveInfo slaveInfo, DeviceModel deviceModel, ushort addrRegister,
        ushort valueRegister);


}